*** This file creates the event study parameter datasets with the 2013 as the last pretreatment year


*** Last updated 6/10/2024

capture log close
set more off
set matsize 11000
* If needed change global path to point to directory where files are stored on your computer
*global path "I:/DataSets5/Duncan/Dropbox/Recent Minimum Wage Changes/2020.12 NBER Update/JOLE Precommittment Replication"

global dtadir "$path/Data"
global tabdir "$path/Tables"
global figdir "$path/Figures"
global estdir "$path/Estimates"
global logdir "$path/Logfiles"

log using "$logdir/event-study-datasets-2013.log", replace

*** Assemble relevant years of ACS 
use "$path/Data/ACS-2019.dta", clear

*** Drop seniors
drop if age >= 65 | age < 16
drop if empstat == 0

*** Construct economic outcomes of interest 
gen employed = 0
replace employed = 1 if  empstat == 1

gen inlaborforce = 0
replace inlaborforce = 1 if labforce == 2

gen unemployed = 0
replace unemployed = 1 if inlaborforce == 1 & employed == 0

**** Construct education variables

gen dropout = 0 
replace dropout = 1 if educ < 6
gen highschool = 0 
replace highschool = 1 if educ == 6
gen somecollege = 0
replace somecollege = 1 if educ >= 7 & educ < 10
gen collegeplus = 0
replace collegeplus = 1 if educ >= 10

***
* Assign the policy categories
***

merge m:1 statefip using "$path/Data/min_wage_variables_for_ACS_and_CPS_analysis.dta"
drop _merge

drop statincreasebydec201*
drop statincreasebyjan20*

gen indexer = 0
replace indexer = 1 if originaltype == "Indexer"
gen StatIncreaserLarge = 0
replace StatIncreaserLarge = 1 if indexer == 0 & (jan2015min - jan2013min) >= 1 & (jan2016min - jan2013min) != .
gen statutoryincreasein2014or2015 = 0
replace statutoryincreasein2014or2015 = 1 if (jan2016min - jan2013min) > 0 & indexer == 0
gen StatIncreaserSmall = 0
replace StatIncreaserSmall = 1 if indexer == 0 & statutoryincreasein2014or2015 == 1 & StatIncreaserLarge == 0


*** Fix weight variable
rename perwt cmpwgt

**
* CHECK STATE POLICY CATEGORIES 
**

tab statefip if StatIncreaserLarge == 1
tab statefip if StatIncreaserSmall == 1
tab statefip if indexer == 1

gen StatIncreaserLarge_t_2010 = StatIncreaserLarge == 1 & year == 2010
gen StatIncreaserLarge_t_2011 = StatIncreaserLarge == 1 & year == 2011
gen StatIncreaserLarge_t_2012 = StatIncreaserLarge == 1 & year == 2012
gen StatIncreaserLarge_t_2014 = StatIncreaserLarge == 1 & year == 2014
gen StatIncreaserLarge_t_2015 = StatIncreaserLarge == 1 & year == 2015
gen StatIncreaserLarge_t_2016 = StatIncreaserLarge == 1 & year == 2016
gen StatIncreaserLarge_t_2017 = StatIncreaserLarge == 1 & year == 2017
gen StatIncreaserLarge_t_2018 = StatIncreaserLarge == 1 & year == 2018
gen StatIncreaserLarge_t_2019 = StatIncreaserLarge == 1 & year == 2019

gen StatIncreaserSmall_t_2010 = StatIncreaserSmall == 1 & year == 2010
gen StatIncreaserSmall_t_2011 = StatIncreaserSmall == 1 & year == 2011
gen StatIncreaserSmall_t_2012 = StatIncreaserSmall == 1 & year == 2012
gen StatIncreaserSmall_t_2014 = StatIncreaserSmall == 1 & year == 2014
gen StatIncreaserSmall_t_2015 = StatIncreaserSmall == 1 & year == 2015
gen StatIncreaserSmall_t_2016 = StatIncreaserSmall == 1 & year == 2016
gen StatIncreaserSmall_t_2017 = StatIncreaserSmall == 1 & year == 2017
gen StatIncreaserSmall_t_2018 = StatIncreaserSmall == 1 & year == 2018
gen StatIncreaserSmall_t_2019 = StatIncreaserSmall == 1 & year == 2019

gen indexer_t_2010 = indexer == 1 & year == 2010
gen indexer_t_2011 = indexer == 1 & year == 2011
gen indexer_t_2012 = indexer == 1 & year == 2012
gen indexer_t_2014 = indexer == 1 & year == 2014
gen indexer_t_2015 = indexer == 1 & year == 2015
gen indexer_t_2016 = indexer == 1 & year == 2016
gen indexer_t_2017 = indexer == 1 & year == 2017
gen indexer_t_2018 = indexer == 1 & year == 2018
gen indexer_t_2019 = indexer == 1 & year == 2019


merge m:1 statefip year using "$path/Data/HousingIndexChanges.dta"
keep if _merge == 3
drop _merge
merge m:1 statefip year using "$path/Data/PersonalIncomeChanges.dta"
keep if _merge == 3
drop _merge

gen mw_jan = . 

forval year = 2011/2019 {
	replace mw_jan = jan`year'min if year == `year'
}

forval year = 2011/2019 {
	gen mw_jan`year'B = mw_jan if year == `year'
	gegen mw_jan`year' = max(mw_jan`year'B), by(statefip)
	drop mw_jan`year'B
}
gen totalchange = mw_jan2019 - mw_jan2011


gen youngadult = age <= 21

capture drop stategroup
gen stategroup = 0
replace stategroup = 1 if totalchange > 0 & totalchange != .
*/

capture drop sample serial hhwt pernum cluster metro met2013 strata gq sex race raced empstat ///
empstatd labforce occ1990 ind1990 wkswork2 uhrswork inctot incwage migrate1 ///
migrate1d migplac1 movedin hcovany hinsemp hinspur hcovpub hinscaid hinscare ///
D4HPI D4lnPersonalIncome stateempD jan*min change*

local large StatIncreaserLarge_t_2010 StatIncreaserLarge_t_2011 StatIncreaserLarge_t_2012 StatIncreaserLarge_t_2014 StatIncreaserLarge_t_2015 StatIncreaserLarge_t_2016 StatIncreaserLarge_t_2017 StatIncreaserLarge_t_2018 StatIncreaserLarge_t_2019
local small StatIncreaserSmall_t_2010 StatIncreaserSmall_t_2011 StatIncreaserSmall_t_2012 StatIncreaserSmall_t_2014 StatIncreaserSmall_t_2015 StatIncreaserSmall_t_2016 StatIncreaserSmall_t_2017 StatIncreaserSmall_t_2018 StatIncreaserSmall_t_2019
local index indexer_t_2010 indexer_t_2011 indexer_t_2012 indexer_t_2014 indexer_t_2015 indexer_t_2016 indexer_t_2017 indexer_t_2018 indexer_t_2019

compress

grstyle init

grstyle color background white
*grstyle graphsize x 7
*grstyle graphsize y 5
grstyle set legend, nobox

*** Analyses of the Low-Skill and Young Groups with varying degrees of control for house prices, income, and past changes in house prices and income

* No controls low-skilled
reghdfe employed `large' `small' `index'  [aw = cmpwgt] if age <= 25 & dropout == 1 & (year >= 2010), absorb(statefip year) cluster(statefip)
parmest,format(estimate min95 max95 %8.3f p %8.1e) saving("$estdir/BaseYear2013/CalendarYearRegressionEmploymentLeastNoControls.dta", replace)

* No controls young
reghdfe employed `large' `small' `index' [aw = cmpwgt] if age <= 21 & (year >= 2010), absorb(statefip year) cluster(statefip)
parmest,format(estimate min95 max95 %8.3f p %8.1e) saving("$estdir/BaseYear2013/CalendarYearRegressionEmploymentYoungNoControls.dta", replace)

* Base controls low-skilled
reghdfe employed `large' `small' `index' lnPersonalIncome HPI [aw = cmpwgt] if age <= 25 & dropout == 1 & (year >= 2010), absorb(statefip year) cluster(statefip)
parmest,format(estimate min95 max95 %8.3f p %8.1e) saving("$estdir/BaseYear2013/CalendarYearRegressionEmploymentLeastBaseControls.dta", replace)

* Base controls young
reghdfe employed `large' `small' `index' lnPersonalIncome HPI  [aw = cmpwgt] if age <= 21 & (year >= 2010), absorb(statefip year) cluster(statefip)
parmest,format(estimate min95 max95 %8.3f p %8.1e) saving("$estdir/BaseYear2013/CalendarYearRegressionEmploymentYoungBaseControls.dta", replace)

* Rich controls low-skilled
reghdfe employed `large' `small' `index' D3lnPersonalIncome D3HPI lnPersonalIncome HPI [aw = cmpwgt] if age <= 25 & dropout == 1 & (year >= 2010), absorb(statefip age educ year) cluster(statefip)
parmest,format(estimate min95 max95 %8.3f p %8.1e) saving("$estdir/BaseYear2013/CalendarYearRegressionEmploymentLeastRichControls.dta", replace)

* Rich controls young
reghdfe employed `large' `small' `index' D3lnPersonalIncome D3HPI lnPersonalIncome HPI [aw = cmpwgt] if age <= 21 & (year >= 2010), absorb(statefip age educ year) cluster(statefip)
parmest,format(estimate min95 max95 %8.3f p %8.1e) saving("$estdir/BaseYear2013/CalendarYearRegressionEmploymentYoungRichControls.dta", replace)


log close
